package com.kobe.game_60;

import java.math.BigDecimal;

public class _55 {

    static StringBuilder sb = new StringBuilder();

    public static BigDecimal reversedNumber(BigDecimal number) {
        sb.delete(0, sb.length());
        sb.append(number);
        sb.reverse();
        return new BigDecimal(sb.toString());
    }

    public static boolean isPalindromic(BigDecimal number) {
        return number.equals(reversedNumber(number));
    }

    public static boolean canProducePalindrome(int number) {
        BigDecimal bd = new BigDecimal(number);
        for (int i = 0; i < 50; i++) {
            bd = bd.add(reversedNumber(bd));
            if (isPalindromic(bd))
                return true;
        }
        return false;
    }

    public static void main(String[] args) {
        int result = 0;
        for (int i = 1; i < 10000; i++) {
            if (!canProducePalindrome(i)) {
                System.out.println(i);
                result++;
            }
        }
        System.out.println(result);
    }

}
